package testdemo;

public class Login {
    private String uerName;
    private String password;


    public  void loginInfo(String uerName, String password)
    throws UserNameException,PasswordException{
        if(!this.uerName.equals(uerName)){
            throw new UserNameException("用户名错误！");
        }

        if(!this.password.equals(password)){
            throw new PasswordException("密码错误");
        }

    }

    public String getUerName() {
        return uerName;
    }

    public void setUerName(String uerName) {
        this.uerName = uerName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public static void main(String[] args) {
        Login login = new Login();
        login.setUerName("zhangsan");
        login.setPassword("123456");

        try{
            login.loginInfo("zhangsan","1234567");
            System.out.println("登录成功！！！");
        }catch (UserNameException e){
            e.printStackTrace();
        }catch (PasswordException e){
            e.printStackTrace();
        }finally {

        }

    }
}
